﻿var currentPosition : Vector3;
var moveDirection : Vector3 = Vector3(0,0,1); //For example
var targetPosition : Vector3;
var speed : float;
var t : float;
var destroyMe : boolean;
 
  function Start() {
       currentPosition = transform.position;
       t = 2;
  }
 
  function Update (){
       t = Mathf.Clamp01(Time.deltaTime + t);
      // transform.position = currentPosition + (moveDirection * t);
      transform.position = Vector3.MoveTowards(transform.position, targetPosition, Time.deltaTime * speed);
//      Debug.Log(transform.position + "" + targetPosition); 
 		if(transform.position == targetPosition){ //&& destroyMe){
 		Destroy(this);
// 		Debug.Log("dead");
 		
 		}
  }
 
  function OnMouseExit() {
     // transform.position = currentPosition;
  }

  function OnDestroy()
  {
  }  